package manage.service;

import m.common.model.util.ModelUpdateUtil;
import m.common.service.Service;
import m.system.cache.CacheUtil;
import m.system.exception.MException;
import m.system.util.GenerateID;
import manage.model.AdminColumn;
import manage.model.AdminLogin;

public class AdminColumnService extends Service {
    public void save(AdminLogin admin,String url,String columnsParamKey,String params) throws MException {
        AdminColumn model= CacheUtil.get(AdminColumn.class,admin.getOid(),columnsParamKey);
        if(null!=model){
            model.setViewParams(params);
            ModelUpdateUtil.updateModel(model,"viewParams");
            CacheUtil.clear(AdminColumn.class,admin.getOid(),columnsParamKey);
        }else{
            model=new AdminColumn();
            model.setOid(GenerateID.generatePrimaryKey());
            model.setAdmin(admin);
            model.setUrl(url);
            model.setColumnsParamKey(columnsParamKey);
            model.setViewParams(params);
            ModelUpdateUtil.insertModel(model);
        }
    }
}
